<script setup lang="ts">
import { reactive, ref, onMounted } from 'vue';
import DynamicForm from '../../components/dynamic-form.vue';
import StoreRoomFormItem from './store-room-form-item.vue';
import { TYPE_LIST } from '/@/api/modules/flow-path/flow-path-warehouse';
import { showLoading } from '@tarojs/taro';

const state: {
  /**
   * 资产列表
   */
  typeList: FlowpathWarehouse.WarehouseTypeListRespType[];
} = reactive({
  typeList: [],
});

onMounted(() => {
  getTypeList();
});

/**
 * 获取产品列表
 */
function getTypeList() {
  showLoading();
  TYPE_LIST({}).then((res) => {
    state.typeList = res.data || [];
  });
}

const dynamicFormRef = ref();
/**
 * 暴露list字段给父组件
 */
defineExpose({ dynamicFormRef });
</script>
<template>
  <dynamic-form button-title="添加物资" title="物资" ref="dynamicFormRef">
    <template #default="{ item }">
      <store-room-form-item :item="item" :type-list="state.typeList" />
    </template>
  </dynamic-form>
</template>
